/*!
\file GraphVisualizer.h
\brief Contains definition of GraphVisualizer class.
\ingroup GUI
*/

#ifndef GRAPHVISUALIZER_H
#define GRAPHVISUALIZER_H

#include"DManager.h"
#include"Action.h"

#include<QWidget>
#include<QVBoxLayout>
#include<QHBoxLayout>
#include<QLabel>
#include<QPushButton>
#include<QScrollArea>

/*!
\class GraphVisualizer
\brief Visualizes a Graph.
Visualizes a Graph. This Graph is shown in its label. This class is fed Actions through the update function, after which it will update its Graph and possibly other classes it has access to.
\ingroup GUI
*/

class GraphVisualizer: public QWidget{
Q_OBJECT
public:
	GraphVisualizer( DManager *graphManager, QWidget *parent = 0 );
	//!< Constructor. Requires only the DManager for the Graph it will represent.
	~GraphVisualizer();
	//!< Destructor.
	
	VisualizationSettings *settings()const{ return m_graphManager->communicator()->settings(); }
	//!< Returns VisualizationSettings used for the Graph it displays.
	
	void update( Action *a );
	//!< Updates the Graph to show Action.
private:
	DManager *m_graphManager;
	
	QVBoxLayout *m_layout;
	QLabel *m_label;
	
	QScrollArea *m_scrollArea;
	
	QPushButton *m_button;
	QPushButton *m_playButton;
	QPushButton *m_stopButton;
	QWidget *m_buttonWidget;
	QHBoxLayout *m_buttonLayout;
private slots:
	void _requestUpdate();
	//!< Causes GraphVisualizer to emit requestUpdate() to its parent. This will update the Graph.
	void _requestPlay();
	//!< Causes GraphVisualizer to emit requestPlay() to its parent. This will continuously update the Graph.
	void _requestStop();
	//!< Causes GraphVisualizer to emit requestStop() to its parent. This will stop continuously updating the Graph.
signals:
	void requestUpdate();
	//!< Request for this GraphVisualizer to be updated once.
	void requestPlay();
	//!< Request for this GraphVisualizer to be updated continuously.
	void requestStop();
	//!< Request for this GraphVisualizer to stop being updated continuously.
};

#endif
